<template>
  <div class="box box-show">
    <el-table :data="list" border :row-class-name="tableColor">
      <el-table-column label="序号" type="index" :show-overflow-tooltip="true" />
      <el-table-column label="需求" prop="projectName" :show-overflow-tooltip="true" />
      <el-table-column label="首次添加时间" prop="createdTime" :show-overflow-tooltip="true" />
      <el-table-column label="首次添加人" prop="xianRen" :show-overflow-tooltip="true" />
      <el-table-column label="成交状态" prop="result" :show-overflow-tooltip="true" />
    </el-table>
    <pagination
      :page-num="params.page"
      :page-size="params.pageSize"
      :on-change="handlePaginationChange"
      :total="total"
    />
  </div>
</template>
<script>
import { tableColor } from '@/utils/common.js';
export default {
  props: {
    details: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      list: [],
      tableColor,
      params: {
        page: 1,
        pageSize: this.$store.state.commonsettings.maxPageSize,
      },
      total: 0,
    };
  },
  mounted() {
    if (this.details) {
      this.getDataPage();
    }
  },
  methods: {
    handlePaginationChange(val) {
      this.params = {
        page: val.pageNum,
        pageSize: val.pageSize,
      };
      this.getDataPage();
    },
    async getDataPage() {
      this.loading = true;
      const res = await this.$api["customer/customers/findAdvisoryDemand"]({
        ...this.params,
        query: { customerId: this.details.id },
      });
      this.loading = false;
      if (res.code !== 200) return this.$message.error(res.msg);
      this.list = res.data.result;
      this.total = res.data.total;
    },
  },
};
</script>
<style lang="scss" scoped>
.margin-top {
  margin-top: 20px;
}
.put-itAway {
  cursor: pointer;
}
.margin-left {
  margin-left: 10px;
}
</style>
